<?php

namespace App\Models;

class CartModel extends RbhBaseModel
{
    protected $table = 'df_cart';

    protected $guarded = [];

    /**
     * 加入购物车
     * @param int $uid
     * @param int $goods_id
     * @param $specData
     * @return mixed
     */
    public static function addCart(int $uid, int $goods_id, $specData): mixed
    {
        return self::create([
            'uid'       => $uid,
            'goods_id'  => $goods_id,
            'goods_sn'  => $specData['goods_sn'],
            'goods_num' => $specData['goods_num'],
            'sid'       => $specData['sid'],
            'goods_info'=> json_encode($specData, JSON_UNESCAPED_UNICODE)
        ]);
    }
}
